<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人资料--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <script>
        ctx = "${ctxPath!}";
    </script>
    <link href="${ctxPath!}/layui/css/layui.css" rel="stylesheet" type="text/css">

</head>
<body class="childrenBody">
<div style="padding:10px 50px 10px 10px">
    <form id="resultForm" method="post" action="${ctxPath!}/console/result/edit" class="layui-form">
        <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc; padding-bottom: 5px;">动物预测</div>
        <div style="text-align: center;">
                <p>选择拥有的特征,点击下方“开始预测”按钮进行预测</p>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                @for(feature in features){
                <input type="checkbox" name="fact" value="${feature.id}" title="${feature.name}">
                @}
            </div>
        </div>
        <div class="layui-form-item" style="text-align: center;">
            <div class="layui-input-block">
                <button id="submitButton" class="layui-btn" lay-submit lay-filter="*">开始预测</button>
            </div>
        </div>
    </form>
</div>
<script src="${ctxPath!}/jquery/jquery.min.js"></script>
<script src="${ctxPath!}/layui/layui.js"></script>
<script src="${ctxPath!}/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
<script src="${ctxPath!}/jqgrid/myjqGrid.js?v=1.0.1"></script>
<script>
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer=layui.layer;
        form.on('submit(*)', function(data){
            var facts="";
            var flag=0;
            $("input:checkbox[name='fact']:checked").each(function() { // 遍历name=pid的多选框
                if(flag==0){
                    facts += $(this).val();
                    flag=1;
                }else{
                    facts +=","+$(this).val();
                }
            });
            $.ajax({
                type:"POST",
                url:"/console/rule/forecast",
                data:{"facts":facts},
                success: function(data){
                    if(data.status == 200){
                        layer.alert(data.msg, {
                            icon: 1,
                            skin: 'layer-ext-moon'
                        });
                    }else{
                        layer.alert(data.msg, {
                            icon: 2,
                            skin: 'layer-ext-moon'
                        });
                    }
                }
            });
            return false; //阻止表单跳转。
        });
    });
    function closeAll() {
        parent.layer.closeAll();
    }
</script>
</body>
</html>